#ifndef COMMANDSERVICE_IMPL_H
#define COMMANDSERVICE_IMPL_H

#include <map>
#include <iostream>
#include <boost/function.hpp>
#include "CommandService.hh"

// CommandServiceの実装クラス
class CommandService_impl
    : public virtual POA_RTMEUS::CommandService,
      public virtual PortableServer::RefCountServantBase
{
protected:
    // Make sure all instances are built on the heap by making the
    // destructor non-public
    //virtual ~CommandServiceSVC_impl();

    //Command is a pair of a boost function object and its help string
    typedef std::pair<boost::function<std::string (std::string& arg)> , std::string > Command;

    //m_command is a map which returns boost function object from command's name
    std::map<std::string,  Command > m_commands;
    typedef std::map<std::string, Command >::iterator CommandItr;
public:
    // standard constructor
    // コンストラクタ
    CommandService_impl();
    // デトラクタ
    virtual ~CommandService_impl();
    // attributes and operations
    // 実装
    virtual char* command(const char *command, const char *argv);
    virtual char* help(const char* command);
    virtual RTMEUS::CommandList* list();
    // コマンドの登録
    void registerCommand(std::string name, std::string help, boost::function<std::string (std::string& arg)> func){
        m_commands[name]=Command(func, help);
    }
};

#endif // COMMANDSERVICE_IMPL_H
